package at.fpmedv.eclipse.helma.ui.skinassist;

import java.util.ArrayList;

import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;

public class SkinAssistProcessor implements IContentAssistProcessor {

	private String[] proposals;
	
	public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
			int offset) {
		calculateProposals();
		ArrayList<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
		for (String proposal: proposals) {
			result.add(new CompletionProposal(proposal, offset, 0, proposal.length() - 3));
		}
		return result.toArray(new ICompletionProposal[result.size()]);
	}

	public IContextInformation[] computeContextInformation(ITextViewer viewer,
			int offset) {
		// TODO Auto-generated method stub
		return null;
	}

	public char[] getCompletionProposalAutoActivationCharacters() {
		char[] result = {'<', '.'};
		return result;
	}

	public char[] getContextInformationAutoActivationCharacters() {
		// TODO Auto-generated method stub
		return null;
	}

	public IContextInformationValidator getContextInformationValidator() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getErrorMessage() {
		return "Whatever";
	}

	private void calculateProposals() {
		ArrayList<String> result = new ArrayList<String>();
		// find current Prototype
		result.add("this. %>");
		proposals = result.toArray(new String[result.size()]);
	}

}
